import 'package:flutter/material.dart';
import 'InheritedProvider.dart';

class ChangeNotifierProvider<T extends ChangeNotifier> extends StatefulWidget {

   const ChangeNotifierProvider({Key? key,required this.data,required this.child}) : super(key: key);

   final T data;
   final Widget child;

   // static T of<T>(BuildContext context) {
   //    final type = _typeOf<InheritedProvider<T>>();
   //    final provider = context.dependOnInheritedWidgetOfExactTypeInheritedProvider<T>();
   //    return provider.data;
   // }

   @override
   State<StatefulWidget> createState() => ChangeNotifierProviderState();

}

class ChangeNotifierProviderState<T extends ChangeNotifier> extends State<ChangeNotifierProvider<T>> {

   @override
   Widget build(BuildContext context) {
      return  InheritedProvider<T> (
         data: widget.data,
         child: widget.child,
      );
   }
}